package com.xxja.order.goods.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xxja.order.goods.shop.pojo.Shop;
import com.xxja.order.goods.shop.pojo.ShopAndGoods;
import com.xxja.order.goods.shop.service.ShopService;
import com.xxja.order.utils.PageRequest;
import com.xxja.order.utils.ResponseBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("shop")
public class ShopController {
    @Autowired
    private ShopService shopService;

    /**
     * 查询店铺
     * @param pageRequest
     * @return
     */
    @GetMapping("query")
    public ResponseEntity findAllShop(PageRequest pageRequest) {
        IPage<Shop> datas = this.shopService.findAllShop(pageRequest.setLimit());
        return ResponseBuilder.responseIpage(datas, 200);
    }

    /**
     *
     * @param id
     * @return
     */
    @GetMapping("one/{id}")
    public ResponseEntity findShopAndGoods(@PathVariable Long id) {
        ShopAndGoods data = this.shopService.findShopAndGoods(id);
        return ResponseBuilder.okEntity(data);
    }

}
